package 上课案例.IODemowuxingyi.src.main.java.org.iosf.controll;

import 上课案例.IODemowuxingyi.src.main.java.org.iosf.menu.Menu;
import 上课案例.IODemowuxingyi.src.main.java.org.iosf.pojo.Goods;
import 上课案例.IODemowuxingyi.src.main.java.org.iosf.service.GoodsService;

import java.util.Scanner;

public class GoodsController {
    Scanner sc;

    public GoodsController() {
        sc = new Scanner(System.in);
    }

    public void startSystem() throws Exception {
        try {
            do {
                GoodsService goodsService = null;
                String goodsId="";
                Goods goods;
                Menu.sysMenu();
                String userSelect=sc.next();
                switch (userSelect){
                    case "1":
                        goods=new Goods();
                        System.out.println("请输入商品ID");
                        goodsId =sc.next();
                        System.out.println("请输入商品mc");
                        String goodsName =sc.next();
                        System.out.println("请输入商品lx");
                        String goodsType =sc.next();
                        System.out.println("请输入商品kc");
                        String inventory =sc.next();
                        System.out.println("请输入商品dj");

                        String price =sc.next();
                        goodsService.addGoods(goods);
                        break;
                    case "2":
                        goodsId="";

                        goodsService.deleteGoods(goodsId);
                        break;
                    case "3":
                        goods=new Goods();
                        goodsService.updateGoods(goods);
                        break;
                    case "4":
                        System.out.println("请输入要删除的商品ID");
                        goodsId=sc.next();
                        goodsService.findGoods(goodsId);
                        break;
                    case "5":
                        goodsService.exit();
                        break;
                }
                System.out.println("按任意键继续");
                System.in.read();
            } while (true);
        } catch (Exception e) {
            System.out.println("系统出错，请重试");
        }
    }
}
